from libavg import avg
from config import Config
from combibutton import CombiButton

class PointsBar(avg.DivNode):
    
    # player name
    __name = "noName"
    
    # player points
    __points = 0
    
    # wind mill conditions
    __condition = 100
    
    __isPlayer1 = True
    
    __pointsAndHealth = None
    
    
    
    # constructor
    def __init__(self, size, parent, isPlayer1):
        
        self.__isPlayer1 = isPlayer1
        
        avg.DivNode.__init__(self, size=(Config.pointsHeight, Config.pointsWidth), parent=parent)
        
        combiPos = Config.pointsLeftBegin
        
        if(not isPlayer1):
            combiPos = Config.pointsRightBegin
            
        self.__pointsAndHealth = CombiButton((Config.pointsWidth, Config.pointsHeight), self, combiPos)
        
        
        
        
        
    
    #
    # points methods 
    #
    def addPoints(self, points):
        self.__points += points
        self.__pointsAndHealth.setPoints(self.__points)
        
    def setPoints(self, points):
        self.__points = points
        self.__pointsAndHealth.setPoints(self.__points)
        
    
    def getPoints(self):
        return self.__points
    
    #
    # name methods 
    #
    def setName(self, name):
        self.__name = name
    
    def getName(self):
        return self.__name
    
    #
    # condition methods 
    
    
    def decrementCondition(self, value):
        self.__condition -= value # WERT VERRINGERN 
        self.__pointsAndHealth.setHealth(self.__condition) # BUTTONTEXT SETZTEN
    
    def setCondition(self,value):
        self.__condition  = 0 
        self.__pointsAndHealth.setHealth(self.__condition)
    
    def getCondition(self): # GIBT ZUSTAND ZURUECK
        return self.__condition 